package com.haofengsoft.scce.controller;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.haofengsoft.scce.adapter.information.ManageAttentionModel;
import com.haofengsoft.scce.db.cache.UserAttentionCache;

/**
 * Created by weiwei on 15/6/25.
 */
public class UserAttentionController {
	private static UserAttentionController instance = null;
	private Context appContext;

	public static synchronized UserAttentionController getInstance(
			Context context) {
		if (instance == null) {
			instance = new UserAttentionController(context);
		}
		return instance;
	}

	public UserAttentionController(Context appContext) {
		this.appContext = appContext;
	}

	public boolean setUserAttention(List<ManageAttentionModel> list) {
		List<ManageAttentionModel> clearList = new ArrayList<ManageAttentionModel>();
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).isAttentionChecked()) {
				clearList.add(list.get(i));
			}
		}
		UserAttentionCache.getInstance()
				.setUserAttention(appContext, clearList);
		return true;
	}
}
